// import resolve from 'rollup-plugin-node-resolve';
// // import uglify from 'rollup-plugin-uglify';
// import { terser } from 'rollup-plugin-terser';
// import commonjs from 'rollup-plugin-commonjs';
// import typescript from 'rollup-plugin-typescript';
import pkg from './package.json';
// import babel from '@rollup/plugin-babel';

import { terser } from 'rollup-plugin-terser';
import resolve from '@rollup/plugin-node-resolve';
import babel from '@rollup/plugin-babel';
import commonjs from '@rollup/plugin-commonjs';
import typescript from '@rollup/plugin-typescript';
import path from 'path'


const terserPlugin = terser({ format: { comments: false } });
const commonjsPlugin = commonjs();
const resolvePlugin = resolve();
const babelPlugin = babel({ babelHelpers: 'bundled' });
const tsPlugin = typescript()
export default {
  input: 'src/index.ts', // 打包入口
  output: [

    { // 打包出口
      file: pkg.browser, // 最终打包出来的文件路径和文件名，这里是在package.json的browser: 'dist/index.js'字段中配置的
      format: 'umd', // umd是兼容amd/cjs/iife的通用打包格式，适合浏览器
      name: 'Painter',
      exports: 'named',
      sourcemap: true,
      plugins: [terserPlugin]
    },
    // { // 打到包UNI
    //   file: 'examples/uni/uni_modules/lime-painter/components/l-painter/painter.js',
    //   format: 'es',//'umd',
    //   name: 'Painter',
    //   exports: 'named',
    //   plugins: [terserPlugin]
    // },
    { // 打到包UNI hybrid
      // file: 'examples/uni/hybrid/html/lime-ui/lime-painter/painter.js',
      file: 'examples/uni/uni_modules/lime-painter/components/l-painter/painter.js',
      // file: path.resolve(__dirname, '../../../test/uniappvue3test/src/components/painter.js') , //' D:/wwwroot/test/uniappvue3test/src/components/l-painter/painter.js',
      format: 'esm',//'umd',
      name: 'Painter',
      exports: 'named',
      plugins: [terserPlugin]
    },
    { // 打到包UNI hybrid
      //file: 'examples/uni/hybrid/html/lime-painter/static/painter.js',
      file: 'examples/uni/uni_modules/lime-painter/static/painter.js',
      format: 'umd',//'umd',
      name: 'Painter',
      exports: 'named',
      plugins: [terserPlugin]
    },
    { // 打包出口
      file: 'examples/web/components/painter.js', // 最终打包出来的文件路径和文件名，这里是在package.json的browser: 'dist/index.js'字段中配置的
      format: 'esm', // umd是兼容amd/cjs/iife的通用打包格式，适合浏览器
      name: 'Painter',
      plugins: [terserPlugin]
    }

  ],
  plugins: [resolvePlugin, commonjsPlugin, babelPlugin, tsPlugin]
  // plugins: [ // 打包插件
  //   resolve(), // 查找和打包node_modules中的第三方模块
  //   commonjs(), // 将 CommonJS 转换成 ES2015 模块供 Rollup 处理
  //   typescript(), // 解析TypeScript
  //   terser(),
  // ]
};